let main_box = document.querySelector("#main_box ul");

let url = decodeURI(location.href).split("?")[1].split("=")[1];
console.log(url);

const xhr1 = new XMLHttpRequest();
xhr1.open("get","http://chst.vip:1234/api/getbrandproductlist?brandtitleid="+url,true);
xhr1.onload = function(){
    if(xhr1.status === 200){
        let res1 = JSON.parse(xhr1.responseText)
        console.log(res1);

        let main_boxs = "";
        res1.result.forEach(item => {
            main_boxs += `<li id="${item.productId}">
                            <a href="#">
                                <div class="left">
                                    ${item.productImg}
                                </div>
                                <div class="right">
                                    <div class="title">
                                        <h4>
                                           ${item.productName}
                                        </h4>
                                        <span>${item.productPrice}</span>
                                    </div>
                                    <div class="other">
                                        <span>${item.productQuote}</span>
                                        <span>${item.productCom}</span>
                                    </div>
                                </div>
                            </a>
                        </li>`
        })
        main_box.innerHTML = main_boxs;

        $("#main_box ul li").click(function(){
            // let e = ev || window.event;
            // let target = e.target || e.srcElement;

            let productID = $(this).prop("id");
            console.log(productID);
            location.href = "../html/branddata.html?productid="+productID;

            // localStorage.setItem("pbox",target.innerHTML);
        })
    }
}
xhr1.send(null);

$(".gotop").click(function(){
    $("html").animate({scrollTop:0},1000);
})